#include <bits/stdc++.h>

using namespace std;

// #define LOCK_GETCHAR
// #define USE_INT_128

#if __cplusplus < 201400
#warning "Please use c++14 or higher."
#define CONSTEXPR_FUNC
#define ENABLE_IF_INT
#else
#define CONSTEXPR_FUNC constexpr
#define ENABLE_IF_INT , enable_if_t<_is_integer<T>, int> = 0
template <class T> constexpr bool _is_integer = numeric_limits<T>::is_integer;
template <> constexpr bool _is_integer<bool> = false;
template <> constexpr bool _is_integer<char> = false;
#ifdef USE_INT_128
template <> constexpr bool _is_integer<__int128> = true;
template <> constexpr bool _is_integer<__uint128_t> = true;
#endif
#endif

#if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(LOCK_GETCHAR)
#define getchar getchar_unlocked
#endif

#define il inline
#define mkp make_pair
#define fi first
#define se second
#define ssz(x) (signed((x).size()))
#define _loop_i_t(j, k) make_signed_t<decltype((j) - (k))>
#define For(i, j, k) for (_loop_i_t(j, k) i = (j); i <= (k); ++i) // NOLINT
#define ForDown(i, j, k)                                                       \
  for (_loop_i_t(j, k) i = (j); i >= decltype(i)(k); --i) // NOLINT
#define eb emplace_back
#ifndef ONLINE_JUDGE
#define FileIO(filename)                                                       \
  freopen(filename ".in", "r", stdin);                                         \
  freopen(filename ".out", "w", stdout)
#else
#define FileIO(filename) void(0)
#endif

using ll = long long;
using uint = unsigned int;
using ull = unsigned long long;
using db = double;
using ldb = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#ifdef USE_INT_128
using lll = __int128_t;
using ulll = __uint128_t;
#endif

// clang-format off
CONSTEXPR_FUNC il ll qpow(ll x, ull y, ll mod){ ll ans = 1; x %= mod; while (y) { if (y & 1) (ans *= x) %= mod; (x *= x) %= mod; y >>= 1; } return ans; }
template<typename T> CONSTEXPR_FUNC il void cmin(T & x, const T &y){ x = min(x, y); }
template<typename T> CONSTEXPR_FUNC il void cmax(T & x, const T &y){ x = max(x, y); }
template<typename T ENABLE_IF_INT> il void read(T &x){ x = 0; int f = 1; int c = getchar(); while (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); } while (isdigit(c)) { x = x * 10 + (c - '0'); c = getchar(); } x *= f; }
template<typename T, typename ... Args> il void read(T &x, Args &... y){ read(x), read(y...); }
// clang-format on

// File head end

namespace {
constexpr ll MAXN = 1e6 + 5, INF = 1e9 + 5;
int _id[MAXN];
struct Node {
  int l, r, mxl, mnr, ans;
  Node() : l(0), r(0), mxl(-INF), mnr(INF), ans(INF) {}
} T[MAXN << 2];
#define lc(p) ((p) << 1)
#define rc(p) ((p) << 1 | 1)
void pu(int p) {
  T[p].ans = min({T[lc(p)].ans, T[rc(p)].ans, T[rc(p)].mnr - T[lc(p)].mxl + 1});
  T[p].mxl = max(T[lc(p)].mxl, T[rc(p)].mxl);
  T[p].mnr = min(T[lc(p)].mnr, T[rc(p)].mnr);
}
void build(int p, int l, int r) {
  T[p].l = l, T[p].r = r;
  if (l == r)
    return _id[l] = p, void();
  int mid = (l + r) >> 1;
  build(lc(p), l, mid), build(rc(p), mid + 1, r);
}
void upd1(int pos, int x) {
  int p = _id[pos];
  T[p].mxl = x;
  for (p >>= 1; p; p >>= 1)
    pu(p);
}
void upd2(int pos, int x) {
  int p = _id[pos];
  T[p].mnr = x;
  for (p >>= 1; p; p >>= 1)
    pu(p);
}
int Q;
multiset<int> allR, allL, R[MAXN], L[MAXN];
void Main() {
  FileIO("stone");
  read(Q), build(1, 1, 1e6);
  while (Q--) {
    char op[5];
    int l, r;
    scanf("%s%d%d", op, &l, &r), r--;
    if (op[0] == 'A') {
      allL.emplace(l), allR.emplace(r), R[r].emplace(l), L[l].emplace(r);
      upd1(r, *prev(R[r].end()));
      upd2(l, *L[l].begin());
    } else {
      allL.erase(allL.find(l)), allR.erase(allR.find(r)),
          R[r].erase(R[r].find(l)), L[l].erase(L[l].find(r));
      upd1(r, R[r].empty() ? -INF : *prev(R[r].end()));
      upd2(l, L[l].empty() ? INF : *L[l].begin());
    }
    assert(!allL.empty() && !allR.empty());
    if (*prev(allL.end()) <= *allR.begin()) {
      int ed = *L[*prev(allL.end())].begin();
      int st = *R[*allR.begin()].begin();
      // cerr << *prev(allL.end()) << ' ' << *allR.begin() << ' ' << st << ' '
      //      << ed << '\n';
      printf("%d\n", ed - st + 1);
    } else {
      printf("%d\n", T[1].ans);
    }
  }
}
} // namespace

signed main() { return Main(), 0; }
